﻿import Rhino.Commons.Facilities
import Rhino.Commons
import Rhino.Security
import Rhino.Security.Interfaces from Rhino.Security
import System.Web.Mvc from System.Web.MVC
import System.Collections.Generic
import System
import WineCellar.Web from WineCellar.Web
import WineCellar.Business.Entities from WineCellar.Business
import WineCellar.Business.Services
import WineCellar.Business.ServiceInterfaces
import WineCellar.Core.Interfaces from WineCellar.Core
import Castle.Core.Interceptor from Castle.Core
import WineCellar.Core.Interceptors from WineCellar.Core
import WineCellar.Business.SecurityInterfaces from WineCellar.Business
import WineCellar.Core.NHibernate from WineCellar.Core
import Parker.Web.Controllers from Parker.Web
import WineCellar.Web.Controllers from WineCellar.Web
import Parker.Business from Parker.Business
import System.Configuration from System.Configuration
import file from main.boo

DefineComponents()

section = System.Configuration.ConfigurationManager.GetSection("winecellarmanager.Tenants") as WineCellar.Web.Helpers.TenantConfigurationSection
if section is not null and section.TenantName is not null:
	if section.TenantName == "Parker":
		//nhibernate
		cfg = "Tenants\\Parker\\Parker.cfg.xml"
		facility NHibernateUnitOfWorkFacility:
		  config = NHibernateUnitOfWorkFacilityConfig().NHibernateConfiguration(cfg)
		//controller
		IoC.Container.Kernel.RemoveComponent("winecontroller")
		Component "winecontroller",WineController of ParkerWine,ParkerWineController:  
			lifestyle Transient
			interceptor LoggingInterceptor
		//service
		Component "parker_wine_service", IEntityService of ParkerWine, ParkerWineService
	if section.TenantName == "Core":
	  //nhibernate
		cfg = "hibernate.cfg.xml"
		facility NHibernateUnitOfWorkFacility:
		  config = NHibernateUnitOfWorkFacilityConfig().NHibernateConfiguration(cfg)